package com.ahuan.utils;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
public class TimeUtil {

    private static String time =  LocalDate.now().getMonth().getValue() + "";//默认获取当前月份


    /**
     * 定时任务：
     * 1. 每天凌晨12:00更新当前月份
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public static void updateDate() {
        time = LocalDate.now().getMonth().getValue() + "";
    }

    public static String getTime(){
        return time;
    }
}
